#include "stdafx.h"
#include "CppUnitTest.h"

#include <SnakeLib/Board.h>
#include <SnakeLib/BoardCodec.h>
#include <SnakeLib/ISolver.h>
#include <SnakeLib/Problem.h>

#include "MySolver/MySolver.h"

#include "SnakeAssert.h"

using namespace snake;
namespace test = Microsoft::VisualStudio::CppUnitTestFramework;

namespace MySolverTests
  {		

  TEST_CLASS(MySolverSuite)
    {
    public:

      TEST_METHOD(Should_When_food_is_higher)
        {
        // Arrange
        auto board =           
          "+--+"
          "|! |"
          "|^ |"
          "+--+";
        EDirection expected = UP;

        // Act, Assert
        Assert::Solve(board, MySolver(), expected);
        }

      TEST_METHOD(DontBreakIntoAWall)
        {
        // Arrange
        auto board =           
          "+--+"
          "|! |"
          "| >|"
          "+--+";
        EDirection expected_up = UP;
        EDirection expected_left = LEFT;

        // Act, Assert
        Assert::Solve(board, MySolver(), expected_up);
        /*Assert::Solve(board, MySolver(), expected_left);
        */
        }

      TEST_METHOD(ShouldBe2_2WhenThisBoard)
        {
        // Arrange
        auto board =           
          "+--+"
          "|  |"
          "| >|"
          "+--+";
        size_t Expected_x = 2;
        size_t Expected_y = 2;

        // Act
        BoardCodec board_codec;
        Problem problem(board_codec.FromString(board));
        size_t Got_x = 0;
        size_t Got_y = 0;

        MySolver().FindHead(problem, Got_x, Got_y);

        //Assert
        test::Assert::AreEqual(Got_x, Expected_x);
        test::Assert::AreEqual(Got_y, Expected_y);

        }
    };
  }